<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Goods extends Model
{
    use HasFactory, SoftDeletes;

    protected $fillable = [
        'category_id', 'name', 'price', 'original_price', 'unit', 'purchase_cost_price',
        'sale_cost_price', 'specification_status', 'specifications', 'head_image', 'images', 'point', 'code',
    ];

    protected $casts = [
        'specifications' => 'array',
        'images' => 'array'
    ];

    public function category()
    {
        return $this->belongsTo(Category::class);
    }

    public function stocks()
    {
        return $this->hasMany(GoodsStoreStock::class);
    }
}
